﻿using Kw.Combinatorics;
using System;

namespace Kw.CombinatoricsExamples
{
    class ProductExample03
    {
        static void Main ()
        {
            int[] ranges = new int[] { 7, 6, 5 };
            long rank = 43;

            // Create a new instance:

            Product pt = new Product (ranges, rank);

            // Assign -1 to Rank to get the last rank:

            pt.Rank = -1;

            // A row can be treating as a string:

            string text = pt.ToString () + "  w=" + pt.Width + ", rank=" + pt.Rank;
            Console.WriteLine (text);

            // Increment/decrement operators will wrap-around if they go past limits:

            ++pt;
            Console.WriteLine ("\n{0}  w={1}, rank={2}", pt, pt.Width, pt.Rank);

            // Create a new product from an array of values:

            pt = new Product (new int[] { 7, 6, 5 }, new int[] { 5, 4, 3 });

            Console.WriteLine ("\n{0}  w={1}, rank={2}", pt, pt.Width, pt.Rank);
        }

        /* Output:

        { 6, 5, 4 }  w=3, rank=209

        { 0, 0, 0 }  w=3, rank=0

        { 5, 4, 3 }  w=3, rank=173

        */
    }
}
